package com.tudouji.project.harvest.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.harvest.domain.Acceptform;
import com.tudouji.project.harvest.service.IAcceptformService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 验收单Controller
 * 
 * @author tudouji
 * @date 2021-05-12
 */
@RestController
@RequestMapping("/harvest/acceptform")
public class AcceptformController extends BaseController
{
    @Autowired
    private IAcceptformService acceptformService;

    /**
     * 查询验收单列表
     */
    @PreAuthorize("@ss.hasPermi('harvest:acceptform:list')")
    @GetMapping("/list")
    public TableDataInfo list(Acceptform acceptform)
    {
        startPage();
        List<Acceptform> list = acceptformService.selectAcceptformList(acceptform);
        return getDataTable(list);
    }

    /**
     * 导出验收单列表
     */
    @PreAuthorize("@ss.hasPermi('harvest:acceptform:export')")
    @Log(title = "验收单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Acceptform acceptform)
    {
        List<Acceptform> list = acceptformService.selectAcceptformList(acceptform);
        ExcelUtil<Acceptform> util = new ExcelUtil<Acceptform>(Acceptform.class);
        return util.exportExcel(list, "acceptform");
    }

    /**
     * 获取验收单详细信息
     */
    @PreAuthorize("@ss.hasPermi('harvest:acceptform:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(acceptformService.selectAcceptformById(guid));
    }

    /**
     * 新增验收单
     */
    @PreAuthorize("@ss.hasPermi('harvest:acceptform:add')")
    @Log(title = "验收单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Acceptform acceptform)
    {
        return toAjax(acceptformService.insertAcceptform(acceptform));
    }

    /**
     * 修改验收单
     */
    @PreAuthorize("@ss.hasPermi('harvest:acceptform:edit')")
    @Log(title = "验收单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Acceptform acceptform)
    {
        return toAjax(acceptformService.updateAcceptform(acceptform));
    }

    /**
     * 删除验收单
     */
    @PreAuthorize("@ss.hasPermi('harvest:acceptform:remove')")
    @Log(title = "验收单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(acceptformService.deleteAcceptformByIds(guids));
    }
}
